{% extends "base.html" %}
{% block content %}

{% import "card_macros.html" as card_macros %}

<div id="wip_data">

<br />
<table id="blocked_report">
    <caption>Cards starting {{ start.strftime("%m/%d/%Y") }} -- {{ end.strftime("%m/%d/%Y") }}</caption>
    <tr>
        <th class="key_col">Card</th>
        <th>Duration</th>
        <th>Started</th>
        <th class="title_col">Title</th>
        <th class="title_col">Blockers</th>
    </tr>

    {% for card in cards %}
    <tr class="{{ loop.cycle('odd', 'even') }} {% if card.blocked %}blocked{% endif %}" id="card_{{ card.key }}">
        <td>
            <a href="{{ card.ticket_system.get_ticket_url() }}">{{ card.key }}</a>
        </td>

        <td>
            {{ card_macros.hours_to_days(card.blocked_time) }}
        </td>

        <td>
            {{ card.start_date.strftime("%m-%d") }}
        </td>

        <td>
            <a href="{{ url_for('card', key=card.key) }}">{{ card.ticket_system_data.get('summary', card.title) }}</a>
        </td>

        <td class="blocked_history">
            <table>
                <tr>
                    <th>Duration</th>
                    <th>Reason</th>
                    <th>Dates</th>
                </tr>

                {% for blocker in card.blockers %}
                <tr {% if blocker.unblocked_at == None %}class="blocked"{% endif %}>
                    <td>{{ card_macros.hours_to_days(blocker.duration) }}</td>
                    <td>{{ blocker.reason }}</td>
                    <td>{{ blocker.blocked_at.strftime("%m-%d") }} - {% if blocker.unblocked_at %}{{ blocker.unblocked_at.strftime("%m-%d") }}{% else %}Ongoing{% endif %}</td>
                </tr>
                {% endfor %}
            </table>
        </td>
    {% endfor %}
</table>
</div>

{% endblock content %}
